import java.lang.reflect.Array;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        int [] array = {1,2,3,4};
        int [] copy = new int[array.length];
        // 从哪里拷贝   从那个地方开始拷贝   粘贴到哪里    从那个地方粘贴    拷贝的长度
        System.arraycopy(array,1,copy,1,array.length-1);
        copy[0] = 99;
        System.out.println(Arrays.toString(copy));
        System.out.println(Arrays.toString(array));

    }



    //数组复制
    public static void main3(String[] args) {
        int [] array = {1,2,3,4};
        int [] ret = Arrays.copyOf(array,array.length);
        ret[0] = 99;
        System.out.println(Arrays.toString(array));
        System.out.println(Arrays.toString(ret));
    }




    public static void main1(String[] args) {
        int [] array = {1,2,3,4,5,6};
        array[0] = 100 ;
        System.out.println(array[0]);
        System.out.println(array[1]);
        System.out.println(array.length);//数组名。length就可以自动求出数组长度


        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }


        for (int x : array){
            System.out.println(x);
        }


        String ret = Arrays.toString(array);
        System.out.println(ret);

    }
}